﻿
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using System.IO;
using System.Net;
using System.Threading;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.ComponentModel;
using System.Data.SqlClient;


namespace WordsMatching
{
    public class weka
    {

        public void main_weka()
        {
           

            MySqlConnection myConnection = new MySqlConnection("user id=root;" +
                                         "password=;server=127.0.0.1; database=weka;Port=3306");

            Scripts script = new Scripts();
           
            script.Build_trigger_script_Data_file();
            script.Build_Trigger_Search_Data();
            int label;
            string target = "start";
            System.Console.WriteLine("\n Starting Engine in Debug Mode.................................................");
            myConnection.Open();
          //  while (target != "exit")
            for (int j=0;j<script.trigger_limit;j++)
            {
            //{
              //  System.Console.Write("Label:");
              //  label =System.Convert.ToInt32( System.Console.ReadLine());
              //  System.Console.Write("Me:");
                target = script.trigger_text[j];  //System.Console.ReadLine();
                script.Get_Target_String_Data(target);
                script.Get_Score_Trigger();



                for (int i = 0; i < script.trigger_limit; i++)
                {
                    try
                    {
                        float avg = (script.semantic_score[i] + script.syntactic_score[i]) / 2;

                        if (j == i)
                        {
                            MySqlCommand myCommand = new MySqlCommand("INSERT INTO weka.data(semantic_score,syntactic_score,lev_distance,average_score,class)" + "values(" + script.semantic_score[i] + "," + script.syntactic_score[i] + "," + script.lev_distance[i] + "," + avg + ",1);", myConnection);
                            MySqlDataReader Reader = myCommand.ExecuteReader();
                            Reader.Close();
                        }
                        else
                        {
                            MySqlCommand myCommand = new MySqlCommand("INSERT INTO weka.data(semantic_score,syntactic_score,lev_distance,average_score)" + "values(" + script.semantic_score[i] + "," + script.syntactic_score[i] + "," + script.lev_distance[i] + "," + avg + ");", myConnection);
                            MySqlDataReader Reader = myCommand.ExecuteReader();
                            Reader.Close();
                        }
                       

                    }


               //  Console.WriteLine("new Description added sucessfully");

                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
               
            }//end of main weka


            myConnection.Close();
        }//end of class weka

    }
}